const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const postcssImporter = require('postcss-import');
const autoprefixer = require('autoprefixer');
const postcssOpacity = require('postcss-opacity');

module.exports = {
  entry: {
    'jquery-3.2.1.min': './src/js/jquery-3.2.1.min.js',
    login: './src/js/login.js',
    main: './src/js/main.js',
    tableExporter: './src/js/tableExporter.js',
  },
  output: {
    publicPath: '/',
    path: path.resolve(__dirname, 'dist'),
    filename: 'js/[name].js'
  },
   module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'buble-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract({
          fallbackLoader: 'style-loader',
          loader: 'css-loader?mininize&sourceMap!postcss-loader'
        })
      },
      {
        test: /\.(png|jpg|gif|eot|woff2|woff|ttf|svg)$/,
        loader: 'url-loader',
      },
    ],
  },

  plugins: [
    new webpack.LoaderOptionsPlugin({
      options: {
        postcss: [
          postcssImporter(),
          autoprefixer(),
          postcssOpacity(),
        ],
        context: __dirname,
      },

    }),

    new ExtractTextPlugin('css/[name].css')
  ],
}

